package com.mike.spring.CustomTag;

import com.alibaba.fastjson.JSON;
import com.mike.spring.CustomTag.Bean.AClass;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;

public class MyBeanDefinitionParser implements BeanDefinitionParser {
    @Override
    public BeanDefinition parse(Element element, ParserContext parserContext) {
        System.out.println(JSON.toJSONString("MyBeanDefinitionParser："+element));
//        System.out.println(JSON.toJSONString(parserContext));
        RootBeanDefinition beanDefinition = new RootBeanDefinition();
        beanDefinition.setBeanClass(AClass.class);
        beanDefinition.getPropertyValues().add("name","MyBeanDefinitionParserParseName");
        parserContext.getRegistry().registerBeanDefinition("parse",beanDefinition);
        return null;
    }
}
